Top Shot Metadata
Get the Top Shot specific metadata for a NFT given the account address and moment id.
Parameters
- account: The Flow Address of the account whose moment data needs to be read
- id: The unique ID for the moment whose data needs to be read
Returns TopShot.TopShotMomentMetadataView
import TopShot from 0xTOPSHOTADDRESS
import MetadataViews from 0xMETADATAVIEWSADDRESS
pub fun main(address: Address, id: UInt64): TopShot.TopShotMomentMetadataView {
let account = getAccount(address)
let collectionRef = account.getCapability(/public/MomentCollection)
.borrow<&{TopShot.MomentCollectionPublic}>()!
let nft = collectionRef.borrowMoment(id: id)!
// Get the Top Shot specific metadata for this NFT
let view = nft.resolveView(Type<TopShot.TopShotMomentMetadataView>())!
let metadata = view as! TopShot.TopShotMomentMetadataView
return metadata
}